import { createRouter, createWebHashHistory, RouteRecordRaw, createWebHistory } from 'vue-router'
import AppLayout from '@/layout/AppLayout.vue'
import productRouter from './modules/product'
import settingRouter from './modules/setting'
import systemRouter from './modules/system'
import orderRouter from './modules/order'
import mediaRouter from './modules/media'
import iframeRouter from './modules/iframe'
import configRouter from './modules/config'

const routes: RouteRecordRaw[] = [
  {
    // path: '/template',
    path: '/',
    name: 'template',
    component: () => import('../views/template/index.vue')
  },
  {
    path: '/',
    component: AppLayout,
    children: [
      {
        path: '', // 默认子路由
        name: 'home',
        component: () => import('../views/home/index.vue'),
        meta: { title: '首页', requiresAuth: true }
      },
      productRouter,
      settingRouter,
      systemRouter,
      orderRouter,
      mediaRouter,
      iframeRouter,
      configRouter,
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/index.vue')
  },
]

const router = createRouter({
  history: createWebHashHistory(), // 路由模式
  routes // 路由规则
})

// 全局前置守卫
router.beforeEach((to, form) => {
})

// 全局后置守卫
router.afterEach(() => {
})

export default router
